layui.use(['form', 'layedit', 'layer', 'laydate'], function(){
    var form = layui.form
        ,layer = layui.layer
        ,layedit = layui.layedit
        ,laydate = layui.laydate;

    //日期
    laydate.render({
        elem: '#date'
    });
    laydate.render({
        elem: '#date1'
    });

    //创建一个编辑器
    var editIndex = layedit.build('LAY_demo_editor');





    //监听提交
    form.on('submit', function(data){
        let url="/logisticsGate/addOrUpdate";
        let dates=data.field;
        console.info(dates);
        $.post(url,dates,function (map){
            if (map.state==1){
                layerClose();
                parent.table.reload('logisticsGate');
                parent.layer.msg(map.message);//父页面提示信息);
            }else {
                layerClose();
                parent.table.reload('logisticsGate');
                parent.layer.msg(map.message);//父页面提示信息);
            }
        },"json")
        return false;
    });
    $("#close_btn").on("click",function () {
        var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
        parent.layer.close(index);
    });


    let gateId=getQueryString('gateId');
    console.info(gateId);
    if (gateId){
        let url="/logisticsGate/selectId";
        let data_={gateId:gateId};
        $.post(url,data_,function (map){
            if (map.state==1){
                form.val('example', map.data);
                console.info(map.data);
            }
            form.render();
        },"json")
    }

});

